package com.utils
{
	public class LoaclTime
	{
		public function LoaclTime()
		{
		}
		
		/**
		 * 2013/10/17 17:44:30::150
		 * @param showMS 是否显示毫秒
		 * @param symbol 日期格式
		 * @param timeSymbol 时间格式
		 */
		public static function timeDateFormat(showMS:Boolean=true,dateSymbol:String = '/',timeSymbol:String=':'):String
		{
			var date:Date = new Date();
			var dateStr:String = date.fullYear + dateSymbol + (date.month+1) + dateSymbol + date.date+'  '+getRightFormat(date.hours)+timeSymbol+getRightFormat(date.minutes)+timeSymbol+getRightFormat(date.seconds) + (showMS?timeSymbol+timeSymbol+date.milliseconds:'');
			return ' ' + dateStr;
		}
		
		/**
		 * 17:44:30::150 2013/10/17
		 * @param showMS 是否显示毫秒
		 * @param dateSymbol 日期格式
		 * @param timeSymbol 时间格式
		 */
		public static function dateTimeFormat(showMS:Boolean=true,dateSymbol:String = '/',timeSymbol:String=':'):String
		{
			var date:Date = new Date();
			var dateStr:String = getRightFormat(date.hours)+timeSymbol+getRightFormat(date.minutes)+timeSymbol+getRightFormat(date.seconds) + (showMS?timeSymbol+timeSymbol+date.milliseconds:'') +'  '+date.fullYear + dateSymbol + (date.month+1) + dateSymbol + date.date;
			return ' ' + dateStr;
		}
		
		/**
		 * 17:44:30::150
		 * @param showMS 是否显示毫秒
		 * @param timeSymbol 时间格式
		 */
		public static function timeFormat(showMS:Boolean=true,timeSymbol:String=':'):String
		{
			var date:Date = new Date();
			var dateStr:String = getRightFormat(date.hours)+timeSymbol+getRightFormat(date.minutes)+timeSymbol+getRightFormat(date.seconds) + (showMS?timeSymbol+timeSymbol+date.milliseconds:'') ;
			return ' ' + dateStr;
		}
		
		/**
		 * 2013/10/17
		 * @param symbol 日期格式
		 */
		public static function dateFormat(dateSymbol:String = '/'):String
		{
			var date:Date = new Date();
			var dateStr:String = date.fullYear + dateSymbol + (date.month+1) + dateSymbol + date.date;
			return ' ' + dateStr;
		}
		
		
		private static function getRightFormat(value:int):String{
			var source:String = value + '';
			if(value < 10){
				source = '0' + value;
			}
			return source + '';
		}
	}
}